import moment from 'moment'
import Vue from 'vue'

let sqlUtil = {};
sqlUtil.dateFormat = function (dateStr, pattern = "YYYY-MM-DD HH:mm:ss") {
	let date = moment(dateStr).isValid()
	if (date && (! /^\d+$/.test(dateStr))) {
		return moment(dateStr).format(pattern);
	} else {
		return dateStr
	}
}
Vue.filter('dateFormat', sqlUtil.dateFormat)

export default sqlUtil